<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>计算属性-get和set方法</title>
  <script src="vue.js"></script>
</head>
<body>
   <script>
      let square = {length:2};

      let vm = new Vue({
         data: square,
         computed: {
            area: {
               get(){
                  return this.length * this.length;
               },
               set(value){
                  this.length = Math.sqrt(value);
               }
            }
         }
      })
      console.log(vm.area);  // 4
      vm.area = 9 
      console.log(vm.length);  // 3
   </script>
</body>
</html>
